package com.zito.health.controller;

import com.zito.health.common.result.PlatformResult;
import com.zito.health.entity.ItemAchievements;
import com.zito.health.entity.ItemSchedule;
import com.zito.health.service.ItemAchievementsService;
import com.zito.health.service.ItemScheduleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目研究人员
 */
@Slf4j
@RestController
@RequestMapping("/item/schedule")
public class ItemScheduleController {

    @Autowired
    private ItemScheduleService itemScheduleService;

    @PostMapping("/save")
    public PlatformResult save(ItemSchedule item){
        if(item.getId() == null){
            itemScheduleService.save(item);
        }else{
            itemScheduleService.update(item);
        }
        return  PlatformResult.success();
    }

    @PostMapping("/update")
    public PlatformResult update(ItemSchedule item){
        itemScheduleService.update(item);
        return  PlatformResult.success();
    }

    @PostMapping("/list")
    public PlatformResult list(ItemSchedule item){
        return PlatformResult.success(itemScheduleService.query(item));
    }

    @PostMapping("/delete")
    public PlatformResult delete(Integer id){
        itemScheduleService.delete(id);
        return  PlatformResult.success();
    }

    @PostMapping("/query")
    public PlatformResult query(ItemSchedule item){
        return PlatformResult.success(itemScheduleService.queryOne(item));
    }
}
